class Photo < ActiveRecord::Base
  belongs_to :photo_set
  acts_as_list :scope => :photo_set
  
  has_many  :comments, :as => :commentable, :conditions => ['published = ?', '1'], :dependent => :destroy

  def photo_set_path
    set = self.photo_set ? photo_set.canonical_name : "uncategorized"
    "#{PHOTOS_PATH}/#{set}"
  end
  
  def path(thumbnail = false)
    "#{photo_set_path}/#{id}#{"_t" if thumbnail}.jpg"
  end
  
  def hide
    self.published = 0
    self.save
  end
end
